package com.scnb.observer.v4;

/**
 * 多个观察者的情况
 */

/**
 * 在被观察者里面加入观察者
 */
class Child {
    private boolean cry = false;
    private Dad d = new Dad();
    private Mum m = new Mum();
    private Dog dog = new Dog();

    public boolean isCry() {
        return cry;
    }

    public void wakeUp() {
        cry = true;
        d.feed();
        m.hug();
        dog.wang();
    }
}

/**
 * 观察者
 */
class Dad {
    public void feed() {
        System.out.println("dad feeding ...");
    }
}

class Mum {
    public void hug() {
        System.out.println("mum hugging ...");
    }
}

class Dog {
    public void wang() {
        System.out.println("dog wang ...");
    }
}

public class Main {
    public static void main(String[] args) {
        Child c = new Child();
        c.wakeUp();
    }

}
